<style type="text/css">
    table
    {
        font-size: 9px;
    }
    
    
    #edit
    {
        opacity: 0.8;
    }   
    #edit:hover
    {
        opacity: 1;
    }
    #del
    {
        opacity: 0.8;
    }
    #del:hover
    {
        opacity: 1;
    }   
    #check
    {
        opacity: 0.8;
    }
    #check:hover
    {
        opacity: 1;
    }
        

</style>
<?php
		$query = "SELECT sodong FROM giaodien";
		$result = DataProvider::ExecuteQuery($query);
		$row = mysql_fetch_array($result);
		$rowsPerPage = $row['sodong'];
        if(!isset($_GET['page'])) //nếu không tồn tại page thì mặc nhiên sẽ là trang 1
		{						//vd: localhost/index.php = localhost/index.php?page=1
			$_GET['page'] = 1;
		}
		$offset = ($_GET['page']-1) * $rowsPerPage; 
?>

<?php
    //chụp lại các biến lưu trong Session
    $TenHienThi   = $_SESSION["TenHienThi"];
    $MaND         = $_SESSION["MaTaiKhoan"]; 
    $MaLND        = $_SESSION["MaLoaiTaiKhoan"];
     
    //truy xuất csdl
    include_once("./template/DataProvider.php");
    
    $query = "SELECT * FROM nguoidung WHERE MaND = '".$MaND."'";
    $result = DataProvider::ExecuteQuery($query);
    $row = mysql_fetch_array($result);
    $TenDangNhap = $row["TenDangNhap"];
    $Email = $row["Email"];
    $CMND = $row["CMND"];
    $SDT = $row["SDT"];
    $DC = $row["DiaChi"];
    $TenHienThi = $row["TenHienThi"]; 
    $url = $row["MaHinh"];
    $kd = $row["kinhdo"];
    $vd = $row["vido"];
    
    //phan loại người dùng
    if($MaLND == 0)
    {
        $LoaiND = 'Seller';
        //neu la seller thi lay ra cac sp
        $query1 = "SELECT * FROM sanpham WHERE MaND = '".$MaND."' AND BiXoa ='0'";
		$query1 .= " LIMIT $offset, $rowsPerPage";
        $result1 =  DataProvider::executeQuery($query1);
        
    }
    if($MaLND == 1)
    {
        $LoaiND = 'Buyer';
    }
    if($MaLND == 2)
    {
        $LoaiND = 'admin';
    }
    
    
    
        
    
?>
<table border="0" style="width: 500px; height: 700px; font-size: 15px;">
<tr>
    <td style="text-align: center;" colspan="3"><h3 style="color: #993300;"><u>THÔNG TIN CÁ NHÂN</u></h3><br /><hr /><br />
    <input type="submit" class="button" value=" Thay Đổi Mật Khẩu " onclick="SuaPassword()"/>
    </td>
</tr>

<tr>
    <td style="color:#003399 ; width: 140px;">Hình đại diện: </td>
    <td><img src="<?php echo $url; ?>" height="150" width="200"/></td>
    <td><input type="submit" class="button" value=" Chỉnh sửa " onclick="SuaHinh()"/></td>
</tr>
<tr>
    <td style="color:#003399 ;">Họ Tên:</td>
    <td style="font-style: oblique; font-size: 14px;"><?php echo $TenHienThi; ?></td>
    <td><input type="submit" class="button" value=" Chỉnh sửa " onclick="SuaTen()"/></td>
</tr>
<tr>
    <td style="color:#003399 ;">Loại Tài Khoản:</td>
    <td style="font-style: oblique; font-size: 14px;"><?php echo $LoaiND; ?></td>
</tr>
<tr>
    <td style="color:#003399 ;">Tên Đăng Nhập:</td>
    <td style="font-style: oblique; font-size: 14px;"><?php echo $TenDangNhap; ?></td>
</tr>
<tr>
    <td style="color:#003399 ;">Email:</td>
    <td style="font-style: oblique; font-size: 14px;"><?php echo $Email; ?></td>
</tr>
<tr>
    <td style="color:#003399 ;">CMND:</td>
    <td style="font-style: oblique; font-size: 14px;"><?php echo $CMND;?></td>
</tr>
<tr>
    <td style="color:#003399 ;">Số ĐT:</td>
    <td style="font-style: oblique; font-size: 14px;"><?php echo $SDT ;?></td>
    <td><input type="submit" class="button" value=" Chỉnh sửa " onclick="SuaSDT()"/></td>
</tr>
<tr>
    <td style="color:#003399 ;">Địa Chỉ:</td>
    <td style="font-style: oblique; font-size: 14px;"><?php echo $DC ;?></td>
    <td><input type="submit" class="button" value=" Chỉnh sửa " onclick="SuaDiaChi()"/></td>
</tr>
<?php
    if($_SESSION["MaLoaiTaiKhoan"] == '0') // nếu là seller thì cho nhap tọa dộ hiên thị tren bản dồ !
    {
?>
<tr>
    <td style="color:#003399 ;">Vị Trí Giao Dịch:</td>
    <td style="font-style: oblique; font-size: 14px;">
    <?php 
        if($vd == "" || $kd == "")
        {
            echo 'Bạn nên nhập thông tin này để dễ dàng cho việc giao dịch. 
            chọn chỉnh sửa để được hướng dẫn chi tiết !' ;
        }
        else
        {
            echo $kd.' , '.$vd ;
        } 
    ?>
    </td>
    <td><input type="submit" class="button" value=" Chỉnh sửa " onclick="SuaToaDo()"/></td>
</tr>
<?php
    }
?>
<tr>
     <td style="text-align: center;" colspan="3"><br /><hr /></td>
</tr>
</table>


<?php /****************Nếu là Seller thi xuất ra phần quản lý sp đã đăng*******/
    
    $stt = 0;
    if($MaLND == 0)
    {
        ?>
        
        
        
        <div style="background: #f5f5f5;">
                <p><h3 style="color: #008ad4;"><u>Các sản phẩm đã đăng</u></h3><br /></p>
                
                <table border="1" cellspacing="0" style="width: 650px; ">         
                    <tr style=" color: white; background: #555;">
                        <td align="center" height="30px" width="6">STT</td>
                        <td align="center" height="30px" width="45">Ngày đăng</td>
                        <td align="center" height="30px" width="50">Tên SP</td>
                        <td align="center" height="30px" width="25">SL còn</td>
                        <td align="center" height="30px" width="25">SL bán</td>
                        <td align="center" height="30px" width="30">SL xem</td>
                        <td align="center" height="30px" width="50">Giá</td>
                        <td align="center" height="30px" width="30">Sửa</td>                        
                        <td align="center" height="30px" width="30">Xóa</td>
                        
                     </tr> 
                     <?php
                     while($row1 = mysql_fetch_array($result1))
                     {
                        $stt++;
                        ?>
                        <tr>
                        <td align="center" ><?php echo $stt; ?></td>
                        <td align="center" ><?php echo $row1['NgayDang'] ?></td>
                        <td align="center" ><?php echo $row1['TenSP'] ?></td>
                        <td align="center" ><?php echo $row1['SoLuongTon'] ?></td>
                        <td align="center" ><?php echo $row1['SoLuongBan'] ?></td>
                        <td align="center" ><?php echo $row1['SoLuotXem'] ?></td>
                        <td align="center" ><?php echo number_format($row1['GiaSP']) ?> VNĐ</td>
                        <td align="center" >
                            <a href="trangchu.php?act=11&id=<?php echo $row1['MaSP']; ?>">
                                <img class="act" id="edit" src="./images/edit-icon.png" height="25" width="25"/>   
                            </a>
                        </td>                        
                        <td align="center" >
                            <a href="trangchu.php?act=15&id=<?php echo $row1['MaSP']; ?>">
                                <img class="act" id="del" src="./images/delete-icon.png" height="25" width="25"/>   
                            </a>
                        </td>

                        </tr>
                        <?php
                     }
                     ?>
                </table>
              <?php 
	//tinh tong so trang
	$sql = "SELECT COUNT(MaSP) AS numrows FROM sanpham WHERE MaND = '".$MaND."' AND BiXoa ='0'";			
	$result = DataProvider::ExecuteQuery($sql) ;
	$row = mysql_fetch_array($result, MYSQL_ASSOC);
	$n = $row['numrows'];
	
	$tong_so_trang = ceil($n/$rowsPerPage);
	$self = $_SERVER['PHP_SELF'];//lay ten file chua doan code do (file dang xem)
								//$PHP_SELF và $_SERVER['PHP_SELF'] là hoàn toàn giống nhau	
	//gan nut BACK
	if($_GET['page'] > 1)
	echo "<a href=".$self."?act=9"."&page=".($_GET['page']-1).' style="background-image:url(./images/bg.jpg); color: black;"> Back'."</a>";
	//tao cac lien ket tuong ung voi cac trang 
	if($tong_so_trang > 1){ //neu chi co 1 page chua san pham thi ko can phan trang
	for($i=1 ; $i<=$tong_so_trang; $i++)
	{
		if($i == $_GET['page'])
		{
			echo ' ['.$i.']'; //in page hien tai, ko can tao lien ket
		}
		else

		echo "<a href=".$self."?act=9"."&page=".$i.' style="color: #0661c2;"> '.$i."</a>";
	}
	}
	//gan nut NEXT
	if($_GET['page'] < $tong_so_trang)
	echo "<a href=".$self."?act=9"."&page=".($_GET['page']+1).' style="background-image:url(./images/bg.jpg); color: black;"> Next'."</a>";
?>  
        </div>
        
        <?php
    }

?>

<?php
		//bien $rowsPerPage ko can lam lai 
        if(!isset($_GET['page2'])) //nếu không tồn tại page thì mặc nhiên sẽ là trang 1
		{						//vd: localhost/index.php = localhost/index.php?page=1
			$_GET['page2'] = 1;
		}
		$offset = ($_GET['page2']-1) * $rowsPerPage; 
?>
<?php
    /***************Nếu là Seller thi xuất ra phần quản lý các hóa đơn*******/
    if($MaLND == 0)
    {
        /*$queryND = " SELECT * FROM NGUOIDUNG WHERE MaND = '".$MaND."' ";
        $resultND=DataProvider::executeQuery($queryND);
        $rowND = mysql_fetch_array($resultND);*/
        
       /* $queryNM=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM nguoidung nd, sanpham sp, chitietddh ct, DonDatHang ddh
            WHERE ddh.MaDDH = ct.MaDDH AND sp.MaND = nd.MaND AND ct.MaSP = sp.MaSP";
        $resultNM = DataProvider::executeQuery($queryNM); */
        
        $queryHD=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP, ct.DaThanhToan
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' ORDER BY ddh.NgayDat DESC";
		$queryHD .= " LIMIT $offset, $rowsPerPage";	
        $resultHD=DataProvider::executeQuery($queryHD);
        
?>
        
        <br /><br /><br /><br /><br />
        <div style="background: #f5f5f5;">
                <p><h3 style="color: #008ad4;"><u>Quản lý đơn đặt hàng</u></h3><br /></p>
                
                <table border="1" cellspacing="0" style="width: 650px;">         
                    <tr style=" color: white; background: #555;">
                        <td align="center" height="30px" width="100px">Tên sản phẩm</td>
                        <td align="center" height="30px" width="50px">Giá sản phẩm</td>
                        <td align="center" height="30px" width="50px">Số lượng</td>
                        <td align="center" height="30px" width="50px">Ngày đặt</td>
                        <td align="center" height="30px" width="100px">Người mua</td>
                        <td align="center" height="30px" width="100px">Tổng tiền</td>
                        <td align="center" height="30px" width="100px">Đã giao dịch</td>
                     </tr>
<?php
            while ($rowHD=mysql_fetch_array($resultHD))
    			{
?>
                <tr>
                    <td align="center" ><?php echo $rowHD['TenSP']; ?></td>
                    <td align="center" ><?php echo number_format($rowHD['GiaCa']); ?></td>
                    <td align="center" ><?php echo $rowHD['SoLuong']; ?></td>
                    <td align="center" ><?php echo $rowHD['NgayDat']; ?></td>
                    <td align="center" ><?php echo $rowHD['TenDangNhap']; ?></td>
                    <td align="center" ><?php echo number_format($rowHD['GiaCa']); ?></td>
                    <td align="center" >
                        <a href="trangchu.php?act=20&id=<?php echo $rowHD['MaDDH']; ?>">
                            <?php
                                if($rowHD['DaThanhToan'] == '0')
                                {
                                    
                            ?>
                            <img id="edit" src="images/delete-icon.png" height="25" width="25"/>
                            <?php
                                }
                                else
                                {
                            ?>
                            <img id="edit" src="images/check-icon.png" height="25" width="25"/>    
                            <?php
                            
                                }
                            ?>       
                        </a>
                    </td>
                </tr>
<?php 
        } 
?>
    	</table>
     </div>
<?php 
	//tinh tong so trang
	//$sql = "SELECT COUNT(MaSP) AS numrows FROM sanpham WHERE MaND = '".$MaND."' AND BiXoa ='0'";
	$queryHD=" SELECT COUNT(ddh.MaDDH) AS numrows
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND 
				ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' ORDER BY ddh.NgayDat DESC";			
	$result = DataProvider::ExecuteQuery($queryHD) ;
	$row = mysql_fetch_array($result, MYSQL_ASSOC);
	$n = $row['numrows'];
	
	$tong_so_trang = ceil($n/$rowsPerPage);
	$self = $_SERVER['PHP_SELF'];//lay ten file chua doan code do (file dang xem)
								//$PHP_SELF và $_SERVER['PHP_SELF'] là hoàn toàn giống nhau	
	//gan nut BACK
	if($_GET['page2'] > 1)
	echo "<a href=".$self."?act=9"."&page2=".($_GET['page2']-1).' style="background-image:url(./images/bg.jpg); color: black;"> Back'."</a>";
	//tao cac lien ket tuong ung voi cac trang 
	if($tong_so_trang > 1){ //neu chi co 1 page chua san pham thi ko can phan trang
	for($i=1 ; $i<=$tong_so_trang; $i++)
	{
		if($i == $_GET['page2'])
		{
			echo ' ['.$i.']'; //in page hien tai, ko can tao lien ket
		}
		else

		echo "<a href=".$self."?act=9"."&page2=".$i.' style="color: #0661c2;"> '.$i."</a>";
	}
	}
	//gan nut NEXT
	if($_GET['page2'] < $tong_so_trang)
	echo "<a href=".$self."?act=9"."&page2=".($_GET['page2']+1).' style="background-image:url(./images/bg.jpg); color: black;"> Next'."</a>";
?>
        
        <br />	
        <br />
        <?php 
            // tháng 1
            $thang1 = 0;
            $thang2 = 0;
            $thang3 = 0;
            $thang4 = 0;
            $thang5 = 0;
            $thang6 = 0;
            $thang7 = 0;
            $thang8 = 0;
            $thang9 = 0;
            $thang10 = 0;
            $thang11 = 0;
            $thang12 = 0;
            $query1=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' AND month(`NgayDat`) = 1 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1 ";
            $result1=DataProvider::executeQuery($query1);
            while($row1 = mysql_fetch_array($result1))
            {
                $thang1 = $thang1 +  $row1['TongTien'];
            }
            
            //thang 2
            $query2=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' AND month(`NgayDat`) = 2 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result2=DataProvider::executeQuery($query2);
            while($row2 = mysql_fetch_array($result2))
            {
                $thang2 = $thang2 +  $row2['TongTien'];
            }
            
            $query3=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' AND month(`NgayDat`) = 3 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result3=DataProvider::executeQuery($query3);
            while($row3 = mysql_fetch_array($result3))
            {
                $thang3 = $thang3 +  $row3['TongTien'];
            }
            
            $query4=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' AND month(`NgayDat`) = 4 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result4=DataProvider::executeQuery($query4);
            while($row4 = mysql_fetch_array($result4))
            {
                $thang4 = $thang4 + $row4['TongTien'];
            }
            
            $query5=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' AND month(`NgayDat`) = 5 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result5=DataProvider::executeQuery($query5);
            while($row5 = mysql_fetch_array($result5))
            {
                $thang5 = $thang5 + $row5['TongTien'];
            }
            
            $query6=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' AND month(`NgayDat`) = 6 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result6=DataProvider::executeQuery($query6);
            while($row6 = mysql_fetch_array($result6))
            {
                $thang6 = $thang6 + $row6['TongTien'];
            }
            
            $query7=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' AND month(`NgayDat`) = 7 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result7=DataProvider::executeQuery($query7);
            while($row7 = mysql_fetch_array($result7))
            {
                $thang7 = $thang7 + $row9['TongTien'];
            }
            
            $query8=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' AND month(`NgayDat`) = 8 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result8=DataProvider::executeQuery($query8);
            while($row8 = mysql_fetch_array($result8))
            {
                $thang8 = $thang8 + $row8['TongTien'];
            }
            
            $query9=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' 
            AND month(`NgayDat`) = 9 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result9=DataProvider::executeQuery($query9);
            while($row9 = mysql_fetch_array($result9))
            {
                $thang9 = $thang9 + $row9['TongTien'];
            }
            
            $query10=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' 
            AND month(`NgayDat`) = 10 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result10=DataProvider::executeQuery($query10);
            while($row10 = mysql_fetch_array($result10))
            {
                $thang10 = $thang10 + $row10['TongTien'];
            }
            
            $query11=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' 
            AND month(`NgayDat`) = 11 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result11=DataProvider::executeQuery($query11);
            while($row11 = mysql_fetch_array($result11))
            {
                $thang11 = $thang11 + $row11['TongTien'];
            }
            
            $query12=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP
            FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
            WHERE ddh.MaDDH = ct.MaDDH AND ddh.MaND = nd.MaND AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = '".$_SESSION['MaTaiKhoan']."' 
            AND month(`NgayDat`) = 12 AND year(`NgayDat` ) = 2013 AND ct.DaThanhToan = 1";
            $result12=DataProvider::executeQuery($query12);
            while($row12 = mysql_fetch_array($result12))
            {
                $thang12 = $thang12 + $row12['TongTien'];
            }
            
        ?>
        <!---------------------- Chart ------------------------>
        
        <div id="graph">Loading Chart...</div>

<script type="text/javascript">
	var myData = new Array
    (
    ['Tháng 1', <?php echo $thang1 / 1000000; ?>], 
    ['2', <?php echo $thang2 / 1000000; ?>], 
    ['3', <?php echo $thang3 / 1000000; ?>], 
    ['4', <?php echo $thang4 / 1000000; ?>], 
    ['5', <?php echo $thang5 / 1000000; ?>], 
    ['6', <?php echo $thang6 / 1000000; ?>], 
    ['7', <?php echo $thang7 / 1000000; ?>], 
    ['8', <?php echo $thang8 / 1000000; ?>], 
    ['9', <?php echo $thang9 / 1000000; ?>], 
    ['10', <?php echo $thang10 / 1000000; ?>], 
    ['11', <?php echo $thang11 / 1000000; ?>], 
    ['12', <?php echo $thang12 / 1000000; ?>]
    );
    
	var colors = ['#2D6B96', '#327AAD', '#3E90C9', '#55A7E3', '#60B6F0', '#81C4F0', '#9CCEF0', '#2D6B96', '#327AAD', '#3E90C9', '#55A7E3', '#60B6F0'];
	var myChart = new JSChart('graph', 'bar');
	myChart.setDataArray(myData);
	myChart.colorizeBars(colors);
	myChart.setTitle('Biểu đồ thống kê giao dịch năm 2013 ( *đơn vị: triệu VND )')
	myChart.setTitleColor('#8E8E8E');
	myChart.setAxisNameX('');
	myChart.setAxisNameY('');
	myChart.setAxisColor('#C4C4C4');
	myChart.setAxisNameFontSize(16);
	myChart.setAxisNameColor('#999');
	myChart.setAxisValuesColor('#777');
	myChart.setAxisColor('#B5B5B5');
	myChart.setAxisWidth(1);
	myChart.setBarValuesColor('#2F6D99');
	myChart.setBarOpacity(0.5);
	myChart.setAxisPaddingTop(60);
	myChart.setAxisPaddingBottom(40);
	myChart.setAxisPaddingLeft(45);
	myChart.setTitleFontSize(11);
	myChart.setBarBorderWidth(0);
	myChart.setBarSpacingRatio(40);
	myChart.setBarOpacity(0.9);
	myChart.setFlagRadius(6);
	myChart.setTooltipPosition('nw');
	myChart.setTooltipOffset(3);
	myChart.setSize(616, 321);
	//myChart.setBackgroundImage('images/chart_bg.jpg');
	myChart.draw();
</script>
        <?php 
        
        }// end
    	else
        {
           $queryBuy=" SELECT ddh.MaDDH, ct.MaSP, ct.GiaCa, ct.SoLuong, ddh.NgayDat, nd.TenDangNhap, ddh.TongTien, sp.TenSP, ct.DaThanhToan, nd.TenHienThi
                    FROM DonDatHang ddh, ChiTietDDH ct, NguoiDung nd, SanPham sp
                    WHERE ddh.MaDDH = ct.MaDDH AND ct.MaSP = sp.MaSP AND ddh.MaNguoiBan = nd.MaND AND ddh.MaND = '".$_SESSION['MaTaiKhoan']."' ORDER BY ddh.NgayDat DESC";
		$queryBuy .= " LIMIT $offset, $rowsPerPage";	
        $resultBuy=DataProvider::executeQuery($queryBuy); 
        ?>
        <div style="background: #f5f5f5;">
                <p><h3 style="color: #008ad4;"><u>Danh sách đơn đặt hàng</u></h3><br /></p>
                
                <table border="1" cellspacing="0" style="width: 650px;">         
                    <tr style=" color: white; background: #555;">
                        <td align="center" height="30px" width="100px">Tên sản phẩm</td>
                        <td align="center" height="30px" width="50px">Giá sản phẩm</td>
                        <td align="center" height="30px" width="50px">Số lượng</td>
                        <td align="center" height="30px" width="50px">Ngày đặt</td>
                        <td align="center" height="30px" width="100px">Người bán</td>
                        <td align="center" height="30px" width="100px">Tổng tiền</td>
                        <td align="center" height="30px" width="100px">Đã nhận</td>
                     </tr>
<?php
            while ($rowHD=mysql_fetch_array($resultBuy))
    			{
?>
                <tr>
                    <td align="center" ><?php echo $rowHD['TenSP']; ?></td>
                    <td align="center" ><?php echo number_format($rowHD['GiaCa']); ?></td>
                    <td align="center" ><?php echo $rowHD['SoLuong']; ?></td>
                    <td align="center" ><?php echo $rowHD['NgayDat']; ?></td>
                    <td align="center" ><?php echo $rowHD['TenHienThi']; ?></td>
                    <td align="center" ><?php echo number_format($rowHD['GiaCa']); ?></td>
                    <td align="center" >
                        <a href="#">
                            <?php
                                if($rowHD['DaThanhToan'] == '0')
                                {
                                    
                            ?>
                            <img id="edit" src="images/delete-icon.png" height="25" width="25"/>
                            <?php
                                }
                                else
                                {
                            ?>
                            <img id="edit" src="images/check-icon.png" height="25" width="25"/>    
                            <?php
                            
                                }
                            ?>       
                        </a>
                    </td>
                </tr>
<?php 
        } 
?>
    	</table>
     </div>
        <?php   
        } 
                
        			
        ?>
        </div>
